package o;

import android.content.Context;
import android.media.AudioAttributes;
import android.media.MediaMetadata;
import android.media.session.MediaController;
import android.media.session.MediaController.Callback;
import android.media.session.MediaController.PlaybackInfo;
import android.media.session.MediaSession.QueueItem;
import android.media.session.MediaSession.Token;
import android.media.session.PlaybackState;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.support.v4.media.session.MediaSessionCompat;
import android.view.KeyEvent;
import androidx.annotation.RequiresApi;
import java.util.List;

@RequiresApi(21)
public class x {

    public interface d {
        void ˊ(Object obj);

        void ˎ(int i, int i2, int i3, int i4, int i5);

        void ˎ(Bundle bundle);

        void ˎ(Object obj);

        void ˏ();

        void ˏ(String str, Bundle bundle);

        void ˏ(List<?> list);

        void ॱ(CharSequence charSequence);
    }

    static class a<T extends d> extends Callback {
        protected final T ˎ;

        public a(T t) {
            this.ˎ = t;
        }

        public void onSessionDestroyed() {
            this.ˎ.ˏ();
        }

        public void onSessionEvent(String str, Bundle bundle) {
            MediaSessionCompat.ˏ(bundle);
            this.ˎ.ˏ(str, bundle);
        }

        public void onPlaybackStateChanged(PlaybackState playbackState) {
            this.ˎ.ˊ(playbackState);
        }

        public void onMetadataChanged(MediaMetadata mediaMetadata) {
            this.ˎ.ˎ((Object) mediaMetadata);
        }

        public void onQueueChanged(List<QueueItem> list) {
            this.ˎ.ˏ(list);
        }

        public void onQueueTitleChanged(CharSequence charSequence) {
            this.ˎ.ॱ(charSequence);
        }

        public void onExtrasChanged(Bundle bundle) {
            MediaSessionCompat.ˏ(bundle);
            this.ˎ.ˎ(bundle);
        }

        public void onAudioInfoChanged(PlaybackInfo playbackInfo) {
            this.ˎ.ˎ(playbackInfo.getPlaybackType(), e.ˏ(playbackInfo), playbackInfo.getVolumeControl(), playbackInfo.getMaxVolume(), playbackInfo.getCurrentVolume());
        }
    }

    public static class e {
        public static AudioAttributes ˋ(Object obj) {
            return ((PlaybackInfo) obj).getAudioAttributes();
        }

        public static int ˏ(Object obj) {
            return ˋ(ˋ(obj));
        }

        private static int ˋ(AudioAttributes audioAttributes) {
            if ((audioAttributes.getFlags() & 1) == 1) {
                return 7;
            }
            if ((audioAttributes.getFlags() & 4) == 4) {
                return 6;
            }
            switch (audioAttributes.getUsage()) {
                case 1:
                case 11:
                case 12:
                case 14:
                    return 3;
                case 2:
                    return 0;
                case 3:
                    return 8;
                case 4:
                    return 4;
                case 5:
                case 7:
                case 8:
                case 9:
                case 10:
                    return 5;
                case 6:
                    return 2;
                case 13:
                    return 1;
                default:
                    return 3;
            }
        }
    }

    public static Object ˊ(Context context, Object obj) {
        return new MediaController(context, (Token) obj);
    }

    public static Object ˎ(d dVar) {
        return new a(dVar);
    }

    public static boolean ˎ(Object obj, KeyEvent keyEvent) {
        return ((MediaController) obj).dispatchMediaButtonEvent(keyEvent);
    }

    public static void ˋ(Object obj, String str, Bundle bundle, ResultReceiver resultReceiver) {
        ((MediaController) obj).sendCommand(str, bundle, resultReceiver);
    }
}
